using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class COUNTRYInfo
    {
		#region Local Variable
		public  enum Field
		{
			COUNTRY_CODE,
			A3,
			COUNTRY_NAME,
			CREATEDBY,
			MODIFIEDBY,
			CREATEDDATE,
			MODIFIEDDATE
		}
		private String _COUNTRY_CODE;
		private String _A3;
		private String _COUNTRY_NAME;
		private String _CREATEDBY;
		private String _MODIFIEDBY;
		private Int32 _CREATEDDATE;
		private Int32 _MODIFIEDDATE;
		
		public String COUNTRY_CODE{	get{ return _COUNTRY_CODE;} set{_COUNTRY_CODE = value;} }
		public String A3{	get{ return _A3;} set{_A3 = value;} }
		public String COUNTRY_NAME{	get{ return _COUNTRY_NAME;} set{_COUNTRY_NAME = value;} }
		public String CREATEDBY{	get{ return _CREATEDBY;} set{_CREATEDBY = value;} }
		public String MODIFIEDBY{	get{ return _MODIFIEDBY;} set{_MODIFIEDBY = value;} }
		public Int32 CREATEDDATE{	get{ return _CREATEDDATE;} set{_CREATEDDATE = value;} }
		public Int32 MODIFIEDDATE{	get{ return _MODIFIEDDATE;} set{_MODIFIEDDATE = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public COUNTRYInfo()
		{
			_COUNTRY_CODE = "";
			_A3 = "";
			_COUNTRY_NAME = "";
			_CREATEDBY = "";
			_MODIFIEDBY = "";
			_CREATEDDATE = 0;
			_MODIFIEDDATE = 0;
		}
		public COUNTRYInfo(
		String COUNTRY_CODE,
		String A3,
		String COUNTRY_NAME,
		String CREATEDBY,
		String MODIFIEDBY,
		Int32 CREATEDDATE,
		Int32 MODIFIEDDATE
		)
		{
			_COUNTRY_CODE = COUNTRY_CODE;
			_A3 = A3;
			_COUNTRY_NAME = COUNTRY_NAME;
			_CREATEDBY = CREATEDBY;
			_MODIFIEDBY = MODIFIEDBY;
			_CREATEDDATE = CREATEDDATE;
			_MODIFIEDDATE = MODIFIEDDATE;
		}
		public COUNTRYInfo(DataRow dr)
		{
			if (dr != null)
			{
				_COUNTRY_CODE = dr[Field.COUNTRY_CODE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.COUNTRY_CODE.ToString()]);
				_A3 = dr[Field.A3.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.A3.ToString()]);
				_COUNTRY_NAME = dr[Field.COUNTRY_NAME.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.COUNTRY_NAME.ToString()]);
				_CREATEDBY = dr[Field.CREATEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CREATEDBY.ToString()]);
				_MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
				_CREATEDDATE = dr[Field.CREATEDDATE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.CREATEDDATE.ToString()]);
				_MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.MODIFIEDDATE.ToString()]);
			}
		}
		public COUNTRYInfo(COUNTRYInfo objEntr)
		{			
			_COUNTRY_CODE = objEntr.COUNTRY_CODE;			
			_A3 = objEntr.A3;			
			_COUNTRY_NAME = objEntr.COUNTRY_NAME;			
			_CREATEDBY = objEntr.CREATEDBY;			
			_MODIFIEDBY = objEntr.MODIFIEDBY;			
			_CREATEDDATE = objEntr.CREATEDDATE;			
			_MODIFIEDDATE = objEntr.MODIFIEDDATE;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("COUNTRY");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.COUNTRY_CODE.ToString(), typeof(String)),
				new DataColumn(Field.A3.ToString(), typeof(String)),
				new DataColumn(Field.COUNTRY_NAME.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDBY.ToString(), typeof(String)),
				new DataColumn(Field.MODIFIEDBY.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDDATE.ToString(), typeof(Int32)),
				new DataColumn(Field.MODIFIEDDATE.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.COUNTRY_CODE.ToString()] = _COUNTRY_CODE;
			row[Field.A3.ToString()] = _A3;
			row[Field.COUNTRY_NAME.ToString()] = _COUNTRY_NAME;
			row[Field.CREATEDBY.ToString()] = _CREATEDBY;
			row[Field.MODIFIEDBY.ToString()] = _MODIFIEDBY;
			row[Field.CREATEDDATE.ToString()] = _CREATEDDATE;
			row[Field.MODIFIEDDATE.ToString()] = _MODIFIEDDATE;
			return row;
		}
        #endregion InitTable
    }
}
